package com.tacx.groupassignment;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

public class BrickMessageBoxMain extends DialogFragment {
	
	int selectedItem = 0;
	
	@Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the Builder class for convenient dialog construction
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.dialog_title_main);
        builder.setItems(R.array.mainBricks_array, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
            // The 'which' argument contains the index position
            // of the selected item
            	selectedItem = which;
            	if (selectedItem == 1) {
                    YellowMessageBox();
                }
            	else if (selectedItem == 2)
            	{
            		GreenMessageBox();
            	}
            	else 
            	{
            		RedMessageBox();
            	}
            }
        });
        return builder.create();
    }
	
	public void RedMessageBox()
	{
		DialogFragment newFragment = new BrickMessageBoxRed();
		newFragment.show(getFragmentManager(), "red");
	}
	
	public void YellowMessageBox()
	{
		DialogFragment newFragment = new BrickMessageBoxYellow();
		newFragment.show(getFragmentManager(), "yellow");
	}
	
	public void GreenMessageBox()
	{
		DialogFragment newFragment = new BrickMessageBoxGreen();
		newFragment.show(getFragmentManager(), "green");
	}
}
